<?php
ob_start();
require_once '../sub/init.php';
require_once 'chkUadm.php';
if(!in_array('u_qianxian',$QXARR) && !CRM_ADM)exit(noauth());
require_once ZEAI.'cache/udata.php';
require_once ZEAI.'cache/config_vip.php';
$qxflagARR = json_decode($_CRM['qxflag'],true);
$sex_ARR  = json_decode($_UDATA['sex'],true);$extifshow = json_decode($_UDATA['extifshow'],true);
$mate_diy = explode(',',$_ZEAI['mate_diy']);
$qianxian_num = json_decode($_VIP['qianxian_num'],true);
$t=trimhtml($t);
$nav='index';
require_once ZEAI.'m/div_left_so.php';?>
<!doctype html><html><head><meta charset="utf-8">
<title><?php echo $_ADM['admSiteName']; ?></title>
<?php echo HEADMETA; ?>
<script src="<?php echo RES;?>www_zeai_cn.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<script src="<?php echo RES;?>m/js/m.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<link href="<?php echo RES;?>m/css/m.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<?php require_once 'm_style.php';?>
<link href="css/m_adm.css?<?php echo $_ZEAI['cache_str'];?>" rel="stylesheet" type="text/css" />
<style>
.ZEAI_list{padding:100px 0 80px;width:92%;margin:0 auto}
.ZEAI_list dl{width:100%;margin:0 auto 12px auto;border-radius:8px;background-color:#fff;box-shadow:0 0 28px rgb(0 0 0 / 8%);position:relative;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;position:relative}
.ZEAI_list dl .tbody{padding:0 10px;margin:0 auto 10px auto;line-height:40px;color:#999;border-bottom:#f5f5f5 1px solid;text-align:left}
.ZEAI_list dl .tbody .hninfo{float:right;color:#333}
.ZEAI_list dl .tbody .hninfo font{color:#999}

.ZEAI_list dl ul{width:100%;margin:12px auto;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}
.ZEAI_list dl ul li{width:33%;float:left;position:relative;text-align:center;box-sizing:border-box;-webkit-box-sizing:border-box;-moz-box-sizing:border-box}
.ZEAI_list dl ul li img.s{width:50px;height:50px;border-radius:50%;object-fit:cover;-webkit-object-fit:cover}
.ZEAI_list dl ul li em font{color:#333;display:inline-block;vertical-align:middle}
.ZEAI_list dl ul li:nth-child(2) h6{margin-top:10px;color:#888;font-size:13px}
.ZEAI_list dl ul li:nth-child(2) i{color:#ccc;font-size:22px}
.ZEAI_list dl ul li:nth-child(2) span{display:block;font-size:14px}

.ZEAI_list dl .bzbox{padding:0 10px 10px;text-align:left}
.ZEAI_list dl .bzbox .pathlist{margin-top:10px}
.ZEAI_list dl .bzbox .pathlist img{margin:0 5px 2px 2px;width:50px;height:50px;object-fit:cover;-webkit-object-fit:cover;border-radius:2px}

.ZEAI_list dl .ubtnbox{border-top:#f5f5f5 1px solid;padding:5px 0 10px;text-align:right}
.ZEAI_list dl .ubtnbox .btn{margin:5px 10px 0 0;padding:0 8px}
.ZEAI_list dl .ubtnbox .sendkind{float:left;margin:10px 0 6px 10px}
</style>
<!--ifrmae up-->
<?php require_once ZEAI.'cache/config_up.php';?>
<script>var up2='<?php echo UP;?>',upMaxMB=<?php echo $_UP['upMaxMB']; ?>,maxnum=5,browser='<?php echo browser();?>',upurl='';
</script>
<script src="<?php echo RES;?>m/js/ZeaiUP.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php
if (is_weixin()){
	require_once ZEAI."api/weixin/jssdk.php";?>
	<script src="<?php echo RES;?>jweixin-1.2.0.js"></script>
	<script>
	wx.config({debug: false,
		appId: '<?php echo $signPackage["appId"];?>',
		timestamp: <?php echo $signPackage["timestamp"];?>,
		nonceStr: '<?php echo $signPackage["nonceStr"];?>',
		signature: '<?php echo $signPackage["signature"];?>',
		jsApiList: ['chooseImage','uploadImage','previewImage','hideMenuItems']
	});
	</script>
<?php }?>
<!--ifrmae up end-->
</head><body>
<?php
/****************************************SQL 开始*****************************************/
$SQL  = "b.kind<>4 AND (b.flag=1 OR b.flag=-2) AND b.crm_flag<>3 ";// AND b.admid>0

$SQL .= ($ifwelcome=='hnid2' && !CRM_ADM)?" AND b.admid>0 AND b.hnid2=".$session_uid:"";

//我的
if($ifmy==1)$SQL .= " AND (a.admid=".$session_uid." )";//归属直接查牵线表了，不找主板故 OR b.hnid=".$session_uid." OR b.hnid2=".$session_uid."
if($ifonline==1)$SQL .= " AND a.admid=".$session_uid;//(b.admid=".$session_uid." OR b.hnid=".$session_uid." OR b.hnid2=".$session_uid." )

//非超管门店+地区 
$SQL .= getAgentSQL('b');

$Skey = trimhtml($Skey);
$Skey2 = trimhtml($Skey2);
if (ifint($Skey)){
	$SQL .= " AND (b.id=$Skey OR a.uid=$Skey) ";
}elseif(!empty($Skey)){
	$SQL .= " AND ( ( b.uname LIKE '%".$Skey."%' ) OR ( b.nickname LIKE '%".$Skey."%' ) OR ( b.nickname LIKE '%".urlencode($Skey)."%' ) )";
}

if (ifint($Skey2)){
	$SQL .= " AND a.admid=$Skey2 ";
}elseif(!empty($Skey2)){
	$SQL .= " AND (  a.admname LIKE '%".$Skey2."%' )";
}
if(!empty($sDATE1)){
	$sDATE1 = strtotime($sDATE1.' 00:00:01');
	$SQL .= " AND ( a.addtime >= '$sDATE1' )";
}
if(!empty($sDATE2)){
	$sDATE2 = strtotime($sDATE2.' 23:59:59');
	$SQL .= " AND ( a.addtime <= '$sDATE2' )";
}
if (ifint($qxflag) || $qxflag==-1)$SQL .= " AND a.flag = $qxflag ";
if (ifint($sendkindd))$SQL .= " AND a.sendkind = $sendkindd ";
if (ifint($uid)){
	$SQL .= " AND (a.senduid=$uid OR a.uid=$uid) ";
	$_ADM['admPageSize']=8;
}
if (ifint($sexx))$SQL .= " AND b.sex=$sexx ";
$SORT = " ORDER BY a.id DESC ";
/*************************************  SQL结束 ********************************************/
$rt = $db->query("SELECT a.*,b.sex,b.grade,b.nickname,b.weixin,b.mob,b.photo_s FROM ".__TBL_QIANXIAN__." a,".__TBL_USER__." b WHERE ".$SQL." AND a.senduid=b.id ".$SORT." LIMIT ".$_ADM['admLimit']);
$total = $db->num_rows($rt);
$searchA = "?qxflag=$qxflag&ifmy=$ifmy";
$mini_title ='红娘服务';
$mini_class='top_mini4 ';
//$miniurl='m_crm_user.php?p='.intval($b);
//$mini_L = '<em onClick="zeai.openurl(\''.$miniurl.'\')"><i class="ico" >&#xeaca;</i><span></span></em>';
$mini_L = '<em onClick="zeai.openurl(\'m_crm.php\')"><i class="ico" >&#xeaca;</i><span></span></em>';
require_once ZEAI.'m/top_mini.php';?>
<a class="so" id="user_search"><i class="ico">&#xe66c;</i><span>筛选</span></a>
<div class="tabmenu tabmenu2 tabmenufix">
    <a href="m_crm_user_bbs.php<?php echo $searchA;?>">跟进列表</a>
    <a href="m_qianxian_list.php<?php echo $searchA;?>" class="ed">牵线列表(<?php echo $total;?>)</a>
</div>
<form id="www_zeai_cn_FORM" class="ZEAI_list" method="get" action="<?php echo SELF; ?>">
	<?php
	if ($total <= 0 ) {
		echo "<div class='nodataico'><i class='ico'>&#xe608;</i>暂无信息<br><br><a class='aBAI' href='javascript:history.back(-1)'>返回上一步</a></div>";
	} else {
		$page_skin=2;$pagemode='mob';$pagesize=8;require_once ZEAI.'sub/page.php';
		$qxflagARR = json_decode($_CRM['qxflag'],true);
		for($i=1;$i<=$pagesize;$i++) {
			$rows = $db->fetch_array($rt,'name');if(!$rows) break;
            $id = $rows['id'];$uidd = $rows['uid'];
            $admid = $rows['admid'];
            $admname = dataIO($rows['admname'],'out');
            $sendnickname = trimhtml(dataIO($rows['nickname'],'out'));
            $sex     = $rows['sex'];
            $grade   = $rows['grade'];
            $bz      = $rows['bz'];
            $flag    = $rows['flag'];
            $senduid = $rows['senduid'];
            $sendkind = $rows['sendkind'];
            $addtime = YmdHis($rows['addtime'],'YmdHi');
            $photo_s = $rows['photo_s'];
            $mob = dataIO($rows['mob'],'out');
            $weixin = dataIO($rows['weixin'],'out');
            $bz = dataIO($rows['bz'],'out');
            $pathlist = $rows['pathlist'];
            if(!empty($photo_s)){
                $photo_s_url = UP.$photo_s;
            }else{
                $photo_s_url = RES.'photo_s'.$sex.'.png';
            }
            //
            $row2 = $db->ROW(__TBL_USER__,"sex,grade,nickname,photo_s,weixin,mob","id=".$uidd,"name");
            if ($row2){
                $sex2      = $row2['sex'];
                $grade2    = $row2['grade'];
                $photo_s2  = $row2['photo_s'];
                $nickname2 = trimhtml(dataIO($row2['nickname'],'out'));
                $mob2      = dataIO($row2['mob'],'out');
                $weixin2   = dataIO($row2['weixin'],'out');
                if(!empty($photo_s2)){
                    $photo_s_url2 = UP.$photo_s2;
                }else{
                    $photo_s_url2 = RES.'photo_s'.$sex2.'.png';
                }
            }
			$flagT = crm_arr_title($qxflagARR,$flag);
			?>
            <dl id="tr<?php echo $id;?>">
            	<div class="tbody">
                	<input type="checkbox" name="list[]" value="<?php echo $id; ?>" uid="<?php echo $uidd; ?>" id="id<?php echo $id; ?>" class="checkskin"><label for="id<?php echo $id; ?>" class="checkskin-label"><i class="i1"></i></label>
                    <div class="hninfo"><font>牵线人：</font><?php echo $admname.' ID:'.$admid;?></div>
				</div>
				<ul>
                    <li onClick="zeai.openurl('<?php echo mHref('crm_u',$senduid);?>')"><img src="<?php echo $photo_s_url;?>" class="s"><em><?php echo uicon($sex.$grade);?><font class="S14"><?php echo $senduid;?></font><div class="C999"><?php echo $sendnickname;?></div></em></li>
                    <li><h6><?php echo $addtime;?></h6><i class="ico">&#xe62d;</i><span><?php echo $flagT;?></span></li>
                    <li onClick="zeai.openurl('<?php echo mHref('crm_u',$uidd);?>')"><img src="<?php echo $photo_s_url2;?>" class="s"><em><?php echo uicon($sex2.$grade2);?><font class="S14"><?php echo $uidd;?></font><div class="C999"><?php echo $nickname2;?></div></em></li>
					<div class="clear"></div>
                </ul>
                <div class="clear"></div>
            	<?php
                if(!empty($pathlist) || !empty($bz)){
					echo '<div class="bzbox"><font class="C999">牵线备注：</font>'.$bz;
                    $ARR=explode(',',$pathlist);
                    if(!empty($pathlist) && count($ARR)>0){
						echo '<div class="pathlist">';
						foreach ($ARR as $V) {?>
							<a href="javascript:;" title="放大" class="zoom" onClick="ZeaiM.piczoom('<?php echo smb(UP.$V,'b'); ?>');"><img src="<?php echo UP.$V;?>"></a><?php
						}
						echo '</div>';
					}
                    echo '</div>';
                }
          		?>             
                <div class="ubtnbox">
                	<span class="sendkind"><font class="C999">发起牵线：</font><?php echo ($sendkind == 1)?'用户主动':'红娘主动';?></span>
                    <?php if($flag != 2){?>
                        <a href="javascript:;" class="btn size2 BAI flag" flag="-1" qxid="<?php echo $id;?>" title2="<?php echo urlencode($senduid.'<font>|</font>'.$sendnickname);?>">牵线失败</a>
                        <a href="javascript:;" class="btn size2 zeaibg flag" flag="2" qxid="<?php echo $id;?>" title2="<?php echo urlencode($senduid.'<font>|</font>'.$sendnickname);?>" photo_s_url="<?php echo $photo_s_url2;?>">牵线成功</a>
                    <?php }?>
                    <div class="clear"></div>
                </div>
            </dl>
			<?php
		}
	}
	?>
</form>
<script>var bg = '<?php echo $_Style['list_bg']; ?>',overbg = '<?php echo $_Style['list_overbg']; ?>',selectbg = '<?php echo $_Style['list_selectbg']; ?>';</script>
<!--div_left_so-->
<div id="rangebox"></div>
<div class="div_left_so" id="user_so">
	<form action="<?php echo SELF;?>" method="get" name="www.yzlove.com" id="ZEAI_CN_FORM_ext">
    	<div class="form_uid">
        <input name="Skey" type="text" class="input" id="Skey" maxlength="20" value="<?php echo $Skey;?>" placeholder="按客户UID/用户名/昵称" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
		</div>
    	<div class="form_uid">
        <input name="Skey2" type="text" class="input" id="Skey2" maxlength="20" value="<?php echo $Skey2;?>" placeholder="按红娘ID/姓名" autocomplete="off">
        <button type="submit" class="ico">&#xe6c4;</button>
		</div>
        <?php
		div_left_so_out(array('tbody'=>'牵线状态','t'=>'qxflag','tv'=>$qxflag,'subkind'=>2,'newarr'=>json_decode($_CRM['qxflag']),'ulcls'=>' col3'));
		div_left_so_out(array('tbody'=>'发起牵线','t'=>'sendkindd','tv'=>$sendkindd,'subkind'=>2,'newarr'=>json_decode('[{"i":"1","v":"用户主动"},{"i":"2","v":"红娘主动"}]'),'ulcls'=>' col3'));
		div_left_so_out(array('tbody'=>'主动方性别','t'=>'sexx','tv'=>$sexx,'subkind'=>2,'newarr'=>json_decode($_UDATA['sex']),'ulcls'=>' col3'));
		div_left_so_out(array('tbody'=>'我牵的','t'=>'ifmy','tv'=>$ifmy,'subkind'=>2,'newarr'=>json_decode('[{"i":"1","v":"我牵的"}]'),'ulcls'=>' col3'));
		?>
        <script>div_left_so_init('user_so')</script>
        <div class="savebox"><button type="button" class="btn size3 reset" onClick="div_left_so_reset('user_so',['t','b','uid'])">重置</button><button type="submit" class="btn size3 zeaibg ico">&#xe6c4; 确定</button></div>
    </form>
</div>
<script>
user_search.onclick=user_searchFn;
function user_searchFn(){ZeaiM.div_left({obj:user_so,w:28});}
</script>
<!--div_left_so end-->
<?php if ($total > 0 ){?>
    <?php echo $page_cls;?>
    <div class="listbottombox">
        <input type="checkbox" id="checkboxall2" class="checkskin checkboxall"><label for="checkboxall2" class="checkskin-label"><i class="i1"></i></label>　
        <button type="button" id="btndellist" class="btn size2 HEI2 disabled action">批量删除</button>　
        <?php if ($total > $pagesize)echo '<div class="pagebox">'.$pagelist.'</div>'; ?>
    </div>
    <div id="backtop"><a id="btmTopBtn"><i class="ico">&#xe60c;</i>顶部</a></div>
    <script>
    document.body.onscroll = backtop_alone;
	zeai.listEach('.flag',function(obj){
		if(!obj.hasClass('disabled'))obj.onclick = function(){
			var id = parseInt(obj.getAttribute("qxid")),
			flag = parseInt(obj.getAttribute("flag")),
			title2 = obj.getAttribute("title2");
			var photo_s_url = decodeURIComponent(obj.getAttribute("photo_s_url"));
			var photo_s_iframeL = (!zeai.empty(photo_s_url))?'<img src="'+photo_s_url+'" class="photo_s_iframeL">':'';
			str = (flag==2)?'确定牵线成功？<br><br>牵线成功将在前台相关页面展示牵线成功信息，如：XXX和XXX牵线成功！':'确定牵线失败？';
			zeai.confirm(str,function(){
				ZeaiM.iframe({title:photo_s_iframeL+'<span>【'+title2+'】牵线管理</span>',url:'m_qianxian.php?submitok=qx_bz&flag='+flag+'&id='+id,fn:function(){
					setTimeout(function(){location.reload(true);},500);	
				}});
			});
		}
	});
	o('btndellist').onclick = function() {
		allList({
			btnobj:this,
			url:'u_qianxian'+zeai.ajxext+'submitok=alldel',
			title:'批量删除',
			msg:'正在删除中...',
			ifjson:true,
			ifconfirm:true
		});	
	}
    </script>
    <script src="js/zeai_tablelist.js?<?php echo $_ZEAI['cache_str'];?>"></script>
<?php }?>
</body></html><?php ob_end_flush();?>